<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" />
<xsl:template match="/">using System;
using System.Data;
using <xsl:value-of select="Schema/@EntityNameSpace" />;
using <xsl:value-of select="Schema/@DataAccessNameSpace" />;

namespace <xsl:value-of select="Schema/@NameSpace" />
{
	public class <xsl:value-of select="Schema/@TableName" />Biz
	{
		public <xsl:if test="Schema/@IsStatic='True'">static </xsl:if>void Add<xsl:value-of select="Schema/@TableName" />(<xsl:value-of select="Schema/@TableName" /> obj<xsl:value-of select="Schema/@TableName" />)
		{
			<xsl:value-of select="Schema/@TableName" />Insert obj<xsl:value-of select="Schema/@TableName" />DAL = new <xsl:value-of select="Schema/@TableName" />Insert();
			obj<xsl:value-of select="Schema/@TableName" />DAL.ReceiveParameter(obj<xsl:value-of select="Schema/@TableName" />);
			obj<xsl:value-of select="Schema/@TableName" />DAL.ExecuteNonQuery();<xsl:for-each select="Schema/Columns[IS_IDENTITY='1']">
			obj<xsl:value-of select="/Schema/@TableName" />.<xsl:value-of select="COLUMN_NAME" /> = obj<xsl:value-of select="/Schema/@TableName" />DAL.<xsl:value-of select="COLUMN_NAME" />;</xsl:for-each>
		}

		public <xsl:if test="Schema/@IsStatic='True'">static </xsl:if>DataTable GetAll<xsl:value-of select="Schema/@TableName" />()
		{
			<xsl:value-of select="Schema/@TableName" />SelectAll obj<xsl:value-of select="Schema/@TableName" />DAL = new <xsl:value-of select="Schema/@TableName" />SelectAll();
			return obj<xsl:value-of select="Schema/@TableName" />DAL.ExecuteDataTable();
		}<xsl:if test="Schema/@IfHavePK=1 and Schema/@IfAllPK=0">

		public <xsl:if test="Schema/@IsStatic='True'">static </xsl:if>void Update<xsl:value-of select="Schema/@TableName" />(<xsl:value-of select="Schema/@TableName" /> obj<xsl:value-of select="Schema/@TableName" />)
		{
			<xsl:value-of select="Schema/@TableName" />Update obj<xsl:value-of select="Schema/@TableName" />DAL = new <xsl:value-of select="Schema/@TableName" />Update();
			obj<xsl:value-of select="Schema/@TableName" />DAL.ReceiveParameter(obj<xsl:value-of select="Schema/@TableName" />);
			obj<xsl:value-of select="Schema/@TableName" />DAL.ExecuteNonQuery();
		}</xsl:if><xsl:if test="Schema/@IfHavePK=1">

		public <xsl:if test="Schema/@IsStatic='True'">static </xsl:if>void Delete<xsl:value-of select="Schema/@TableName" />(<xsl:for-each select="Schema/Columns[IS_PK='1']"><xsl:value-of select="concat(LANGUAGE_TYPE,' ',COLUMN_NAME)" /><xsl:if test="position()!=last()">,</xsl:if></xsl:for-each>)
		{
			<xsl:value-of select="Schema/@TableName" />Delete obj<xsl:value-of select="Schema/@TableName" />DAL = new <xsl:value-of select="Schema/@TableName" />Delete();<xsl:for-each select="Schema/Columns[IS_PK='1']">
			obj<xsl:value-of select="/Schema/@TableName" />DAL.<xsl:value-of select="COLUMN_NAME" /> = <xsl:value-of select="COLUMN_NAME" />;</xsl:for-each>
			obj<xsl:value-of select="Schema/@TableName" />DAL.ExecuteNonQuery();
		}

		public <xsl:if test="Schema/@IsStatic='True'">static </xsl:if><xsl:value-of select="Schema/@TableName" /> Get<xsl:value-of select="Schema/@TableName" />(<xsl:for-each select="Schema/Columns[IS_PK='1']"><xsl:value-of select="concat(LANGUAGE_TYPE,' ',COLUMN_NAME)" /><xsl:if test="position()!=last()">,</xsl:if></xsl:for-each>)
		{
			<xsl:value-of select="Schema/@TableName" />SelectByPk obj<xsl:value-of select="Schema/@TableName" />DAL = new <xsl:value-of select="Schema/@TableName" />SelectByPk();
			<xsl:value-of select="Schema/@TableName" /> obj<xsl:value-of select="Schema/@TableName" /> = new <xsl:value-of select="Schema/@TableName" />();<xsl:for-each select="Schema/Columns[IS_PK='1']">
			obj<xsl:value-of select="/Schema/@TableName" />DAL.<xsl:value-of select="COLUMN_NAME" /> = <xsl:value-of select="COLUMN_NAME" />;</xsl:for-each>
			obj<xsl:value-of select="Schema/@TableName" />.SetMetaDataTable(obj<xsl:value-of select="Schema/@TableName" />DAL.ExecuteDataTable());
			return obj<xsl:value-of select="Schema/@TableName" />;
		}
</xsl:if>
<xsl:for-each select="Schema/ForeignKeys/ForeignKey">
		public <xsl:if test="/Schema/@IsStatic='True'">static </xsl:if>DataTable Get<xsl:value-of select="/Schema/@TableName" />By<xsl:for-each select="Column"><xsl:value-of select="FKCOLUMN_NAME" /><xsl:if test="position()!=last()">AND</xsl:if></xsl:for-each>(<xsl:for-each select="Column"><xsl:value-of select="concat(LANGUAGE_TYPE,' ',FKCOLUMN_NAME)" /><xsl:if test="position()!=last()">,</xsl:if></xsl:for-each>)
		{
			<xsl:value-of select="/Schema/@TableName" />SelectBy<xsl:for-each select="Column"><xsl:value-of select="FKCOLUMN_NAME" /><xsl:if test="position()!=last()">AND</xsl:if></xsl:for-each> obj<xsl:value-of select="/Schema/@TableName" />DAL = new <xsl:value-of select="/Schema/@TableName" />SelectBy<xsl:for-each select="Column"><xsl:value-of select="FKCOLUMN_NAME" /><xsl:if test="position()!=last()">AND</xsl:if></xsl:for-each>();<xsl:for-each select="Column">
			obj<xsl:value-of select="/Schema/@TableName" />DAL.<xsl:value-of select="FKCOLUMN_NAME" /> = <xsl:value-of select="FKCOLUMN_NAME" />;</xsl:for-each>
			return obj<xsl:value-of select="/Schema/@TableName" />DAL.ExecuteDataTable();
		}
</xsl:for-each>	}
}</xsl:template>
</xsl:stylesheet>